<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 闭包, 不能被销毁
        function base () {
            var btnLogin = 0
            return function() {
                btnLogin++
                console.log(btnLogin)
            }
        }
        
        let b = base()
        b()
        b()
        b()
        b()

        // 销毁变量, 不在占用内存
        // let temp = 10;
        // console.log(temp);
        // temp = undefined;
        // // 
        // temp = function() {
        //     let name = '石兴龙'
        //     console.log(name);
        // }
        // temp()
        
        // 控制作用域.
        ;(function(module) {
            let test = function() {
            }
            test.prototype.sum = function() {

            }

            console.log(module)
            module.exports = test
        })({
            module: {
                exports: null
            }
        });

    </script>
</body>
</html>